<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <textarea>

    </textarea>
    <button>发布</button>
    <ul>

    </ul>
</body>
</html>
<script>
    var button=document.querySelector("button")
    var textarea=document.querySelector("textarea")
    var ul=document.querySelector("ul")
    button.onclick=function(){
        if(textarea.value.trim()==''){
            alert('不能为空')
            return
        }
        var li=document.createElement("li")
        li.innerHTML=textarea.value
        ul.appendChild(li)
        textarea.value=''
    }
</script>